﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Shapes;
using RedBit.OAuthLibrary;
using TradeMeSDK;

namespace TradeMo
{
    public class TradeMoSetup
    {
        public bool HideBackground { get; set; }
    }

    public class MainViewModel : BaseViewModel
    {
        public List<SelectorItem<SearchType>> SearchTypes { get; set; }
        private SearchResults _generalSearchResults;

        private TradeMoSetup _setup;
        public TradeMoSetup Setup
        {
            get { return _setup ?? (_setup = new TradeMoSetup()); }
            set { _setup = value; }
        }

        public readonly SelectorItem<SearchType> General = new SelectorItem<SearchType> { Title = "General", Picture = "/Images/general.png", Item = SearchType.General };
        public readonly SelectorItem<SearchType> UsedCars = new SelectorItem<SearchType> { Title = "Used Cars", Picture = "/Images/car.png", Item = SearchType.UsedCars };
        public readonly SelectorItem<SearchType> Boats = new SelectorItem<SearchType> { Title = "Boats", Picture = "/Images/boat.png", Item = SearchType.Boats };
        public readonly SelectorItem<SearchType> Bikes = new SelectorItem<SearchType> { Title = "Bikes", Picture = "/Images/motorbike.png", Item = SearchType.Bikes };
        public readonly SelectorItem<SearchType> Jobs = new SelectorItem<SearchType> { Title = "Jobs", Picture = "/Images/jobs.png", Item = SearchType.Jobs };
        public readonly SelectorItem<SearchType> Residential = new SelectorItem<SearchType> { Title = "Residential", Picture = "/Images/property.png", Item = SearchType.Residential };
        public readonly SelectorItem<SearchType> Rental = new SelectorItem<SearchType> { Title = "Rental", Picture = "/Images/property.png", Item = SearchType.Rental };
        public readonly SelectorItem<SearchType> OpenHomes = new SelectorItem<SearchType> { Title = "Open Homes", Picture = "/Images/property.png", Item = SearchType.OpenHomes };
        public readonly SelectorItem<SearchType> Flatmates = new SelectorItem<SearchType> { Title = "Flatmates", Picture = "/Images/property.png", Item = SearchType.Flatmates };
        //public readonly SelectorItem<SearchType> Rural = new SelectorItem<SearchType> { Title = "Rural", Picture = "/Images/property.png", Item = SearchType.Rural };
        //public readonly SelectorItem<SearchType> Lifestyle = new SelectorItem<SearchType> { Title = "Lifestyle", Picture = "/Images/property.png", Item = SearchType.Lifestyle };
        //public readonly SelectorItem<SearchType> Retirement = new SelectorItem<SearchType> { Title = "Retirement", Picture = "/Images/property.png", Item = SearchType.Retirement };
        //public readonly SelectorItem<SearchType> Commercial = new SelectorItem<SearchType> { Title = "Commercial", Picture = "/Images/commercial.png", Item = SearchType.Commercial };
        //public readonly SelectorItem<SearchType> CommercialLease = new SelectorItem<SearchType> { Title = "Commercial Lease", Picture = "/Images/commercial.png", Item = SearchType.CommercialLease };

        public MainViewModel()
        {
            SearchTypes = new List<SelectorItem<SearchType>>
                       {
                           General, 
                           UsedCars, 
                           Boats, Bikes, Jobs,
                           Residential, Rental, OpenHomes, Flatmates,
                           //Rural, Lifestyle, Retirement, Commercial, CommercialLease
                       };
            SelectedSearchTypeSelector = General;
        }

        public void CheckTrademeCatalog(Control caller)
        {
            if (App.TradeMe.Catalog.IsDownloaded) return;
            if (IsSearching) return;

            IsSearching = true;
            Message = "Updating TradeMe Catalog";
            VisualStateManager.GoToState(caller, "ShowMessage", true);
            App.TradeMe.Catalog.DownloadCompleted += (s, e) =>
            {
                IsSearching = false;
                TradeMeDispatcher.OnUIThread(() => 
                        VisualStateManager.GoToState(caller, "HideMessage", true));
                RootCategories = null;  // Force reload
            };
            App.TradeMe.Catalog.Download();
        }

        private string _message;
        public string Message
        {
            get { return _message; }
            set { _message = value; NotifyPropertyChanged("Message"); }
        }


        private string _searchText;
        public string SearchText
        {
            get { return _searchText; }
            set { _searchText = value; NotifyPropertyChanged("SearchText"); }
        }


        private SelectorItem<SearchType> _selectedSearchTypeSelector;
        public SelectorItem<SearchType> SelectedSearchTypeSelector
        {
            get { return _selectedSearchTypeSelector; }
            set
            {
                _selectedSearchTypeSelector = value ?? General;
                ClearSearch();
                NotifyPropertyChanged("SearchTypeName");
                NotifyPropertyChanged("SearchTypeImage");
                SearchText = "";
            }
        }

        public string SearchTypeImage
        {
            get
            {
                return SelectedSearchTypeSelector != null ? SelectedSearchTypeSelector.Picture : "";
            }
        }

        public string SearchTypeName
        {
            get
            {
                return SelectedSearchTypeSelector != null ? SelectedSearchTypeSelector.Title : "";
            }
        }

        private bool _isSearching;
        public bool IsSearching
        {
            get { return _isSearching; }
            set { _isSearching = value; NotifyPropertyChanged("IsSearching"); }
        }

        public bool LoggedIn
        {
            get { return App.TradeMe.IsLoggedIn; }
        }

        public string LoginImage
        {
            get
            {
                return App.TradeMe.IsLoggedIn ? "/Images/padlock_closed.png" : "/Images/key.png";
            }
        }

        private ObservableCollection<SearchResultItem> _searchResults;
        public ObservableCollection<SearchResultItem> SearchResults
        {
            get { return _searchResults ?? (_searchResults = new ObservableCollection<SearchResultItem>()); }
        }

        private GeneralSearchCriteriaViewModel _generalSearchCriteriaModel;
        public GeneralSearchCriteriaViewModel GeneralSearchCriteriaModel
        {
            get
            {
                return _generalSearchCriteriaModel ??
                       (_generalSearchCriteriaModel = new GeneralSearchCriteriaViewModel());
            }
            set { _generalSearchCriteriaModel = value; }
        }

    	private CriteriaBikesViewModel _criteriaBikesModel;
    	public CriteriaBikesViewModel CriteriaBikesModel
    	{
    		get { return _criteriaBikesModel ?? (_criteriaBikesModel = new CriteriaBikesViewModel()); }
    		set { _criteriaBikesModel = value; }
    	}

    	private CriteriaUsedCarsViewModel _criteriaUsedCarsModel;
    	public CriteriaUsedCarsViewModel CriteriaUsedCarsModel
    	{
    		get { return _criteriaUsedCarsModel ?? (_criteriaUsedCarsModel = new CriteriaUsedCarsViewModel()); }
    		set { _criteriaUsedCarsModel = value; }
    	}

        private CriteriaBoatsViewModel _criteriaBoatsModel;
        public CriteriaBoatsViewModel CriteriaBoatsModel
        {
            get { return _criteriaBoatsModel ?? (_criteriaBoatsModel = new CriteriaBoatsViewModel()); }
            set { _criteriaBoatsModel = value; }
        }

        private CriteriaJobsViewModel _criteriaJobsModel;
        public CriteriaJobsViewModel CriteriaJobsModel
        {
            get { return _criteriaJobsModel ?? (_criteriaJobsModel = new CriteriaJobsViewModel()); }
            set { _criteriaJobsModel = value; }
        }

        private CriteriaPropertyForSaleViewModel _criteriaPropertyForSaleModel;
        public CriteriaPropertyForSaleViewModel CriteriaPropertyForSaleModel
        {
            get { return _criteriaPropertyForSaleModel ?? (_criteriaPropertyForSaleModel = new CriteriaPropertyForSaleViewModel()); }
            set { _criteriaPropertyForSaleModel = value; }
        }

        private CriteriaPropertyRentalViewModel _criteriaPropertyRentalModel;
        public CriteriaPropertyRentalViewModel CriteriaPropertyRentalModel
        {
            get { return _criteriaPropertyRentalModel ?? (_criteriaPropertyRentalModel = new CriteriaPropertyRentalViewModel()); }
            set { _criteriaPropertyRentalModel = value; }
        }

        private CriteriaPropertyForSaleViewModel _criteriaPropertyOpenHomeModel;
        public CriteriaPropertyForSaleViewModel CriteriaPropertyOpenHomeModel
        {
            get { return _criteriaPropertyOpenHomeModel ?? (_criteriaPropertyOpenHomeModel = new CriteriaPropertyForSaleViewModel()); }
            set { _criteriaPropertyOpenHomeModel = value; }
        }

        private CriteriaPropertyFlatmateViewModel _criteriaPropertyFlatmateModel;
        public CriteriaPropertyFlatmateViewModel CriteriaPropertyFlatmateModel
        {
            get { return _criteriaPropertyFlatmateModel ?? (_criteriaPropertyFlatmateModel = new CriteriaPropertyFlatmateViewModel()); }
            set { _criteriaPropertyFlatmateModel = value; }
        }


        private ObservableCollection<Category> _breadcrumb;
        public ObservableCollection<Category> Breadcrumb
        {
            get { return _breadcrumb ?? (_breadcrumb = new ObservableCollection<Category>()); }
        }

        private RecentViewModel _recent;
        public RecentViewModel Recent
        {
            get { return _recent ?? (_recent = new RecentViewModel()); }
            set { _recent = value; NotifyPropertyChanged("Recent"); }
        }

        public void UpdateViewModel()
        {
            NotifyPropertyChanged("LoginImage");
        }

        public void DoSearch()
        {
            if (!string.IsNullOrEmpty(SearchText))
				SearchText = SearchText.Trim();

            ClearSearch();
            switch (SelectedSearchTypeSelector.Item)
            {
                case SearchType.General:
                    GeneralSearchCriteriaModel.Criteria.SearchString = SearchText;
                    DoGeneralSearch(GeneralSearchCriteriaModel.Criteria);
                    break;

				case SearchType.Bikes:
            		CriteriaBikesModel.Criteria.SearchString = SearchText;
            		DoBikesSearch(CriteriaBikesModel.Criteria);
            		break;

				case SearchType.UsedCars:
            		CriteriaUsedCarsModel.Criteria.SearchString = SearchText;
            		DoUsedCarsSearch(CriteriaUsedCarsModel.Criteria);
            		break;

                case SearchType.Boats:
                    CriteriaBoatsModel.Criteria.SearchString = SearchText;
                    DoBoatsSearch(CriteriaBoatsModel.Criteria);
                    break;

                case SearchType.Jobs:
                    CriteriaJobsModel.Criteria.SearchString = SearchText;
                    DoJobSearch(CriteriaJobsModel.Criteria);
                    break;

                case SearchType.Residential:
                    CriteriaPropertyForSaleModel.Criteria.SearchString = SearchText;
                    DoPropertyForSaleSearch(CriteriaPropertyForSaleModel.Criteria);
                    break;

                case SearchType.Rental:
                    CriteriaPropertyRentalModel.Criteria.SearchString = SearchText;
                    DoPropertyRentalSearch(CriteriaPropertyRentalModel.Criteria);
                    break;

                case SearchType.OpenHomes:
                    CriteriaPropertyOpenHomeModel.Criteria.SearchString = SearchText;
                    DoPropertyOpenHomeSearch(CriteriaPropertyOpenHomeModel.Criteria);
                    break;

                case SearchType.Flatmates:
                    CriteriaPropertyFlatmateModel.Criteria.SearchString = SearchText;
                    DoPropertyFlatmateSearch(CriteriaPropertyFlatmateModel.Criteria);
                    break;

                default:
                    IsSearching = false;
                    MessageBox.Show("Coming soon");
                    return;
            }
        }

    	public void DoSearchMore()
        {
            IsSearching = true;
            SetLoadMore(0, 0);

            switch (SelectedSearchTypeSelector.Item)
            {
                case SearchType.General:
                    // Page 0 == Page 1
                    if (GeneralSearchCriteriaModel.Criteria.PageNumber == 0)
                        GeneralSearchCriteriaModel.Criteria.PageNumber = 2;
                    else
                        GeneralSearchCriteriaModel.Criteria.PageNumber++;
                    App.TradeMe.Search.General(GeneralSearchCriteriaModel.Criteria, OnSearchResults);
                    break;
                default:
                    IsSearching = false;
                    break;
            }
        }

        public void ClearSearch()
        {
            SearchResults.Clear();
            SetTotalCount(0);
            SetDidYouMean(null);
            SetLoadMore(0, 0);

            GeneralSearchCriteriaModel.Criteria.PageNumber = 0;
        }

        private void SetTotalCount(int count)
        {
            TotalCount = count == 0 ? "No results" : "Total Count: " + count;
        }

        private void SetDidYouMean(string value)
        {
            _didYouMeanText = value;
            if (string.IsNullOrEmpty(value))
                DidYouMean = "";
            else
                DidYouMean = "Did you mean: " + value + "?";
        }

        private string _totalCount;
        public string TotalCount
        {
            get { return _totalCount; }
            set { _totalCount = value; NotifyPropertyChanged("TotalCount"); }
        }

        private string _didYouMean;
        private string _didYouMeanText;

        public string DidYouMean
        {
            get { return _didYouMean; }
            set { _didYouMean = value; NotifyPropertyChanged("DidYouMean"); NotifyPropertyChanged("ShowDidYouMean"); }
        }
        public bool ShowDidYouMean { get { return !string.IsNullOrEmpty(DidYouMean); } }

        private bool _showLoadMore;
        private string _loadMoreText;
        public string LoadMoreText
        {
            get { return _loadMoreText; }
        }
        public bool ShowLoadMore
        {
            get { return _showLoadMore; }
        }
        private void SetLoadMore(int totalCount, int currentCount)
        {
            if (currentCount < totalCount)
            {
                _showLoadMore = true;
                _loadMoreText = string.Format("{0} of {1} loaded.  Load more", currentCount, totalCount);
            }
            else
                _showLoadMore = false;
            NotifyPropertyChanged("LoadMoreText");
            NotifyPropertyChanged("ShowLoadMore");
        }

        private SearchResultItem _selectedResult;
        public SearchResultItem SelectedResult
        {
            get { return _selectedResult; }
            set
            {
                _selectedResult = value;
                if (_selectedResult == null) return;

                // Open New page for selected listing
            }
        }

        private void OnSearchResults(BaseEventArgs<SearchResults> results)
        {
            IsSearching = false;
            if (results.IsError)
            {
                MessageBox.Show("Bugger: Unable to show results");
                return;
            }

            _generalSearchResults = results.Response;
            SetTotalCount(_generalSearchResults.TotalCount);
            SetDidYouMean(_generalSearchResults.DidYouMean);

            foreach (var listing in _generalSearchResults.List)
                SearchResults.Add(SearchResultItem.Build(listing));

            SetLoadMore(_generalSearchResults.TotalCount, SearchResults.Count);
        }

        public void ChangeSearchTextToDidYouMean()
        {
            SearchText = _didYouMeanText;
            DoSearch();
        }

        public void DoShowRecentSearch(SearchCriteria criteria)
        {
            if (criteria is SearchGeneralCriteria)
            {
                GeneralSearchCriteriaModel.Criteria = criteria as SearchGeneralCriteria;
                DoGeneralSearch(GeneralSearchCriteriaModel.Criteria);
            }
			if (criteria is SearchMotorBikesCriteria)
			{
				CriteriaBikesModel.Criteria = criteria as SearchMotorBikesCriteria;
				DoBikesSearch(CriteriaBikesModel.Criteria);
			}
			if (criteria is SearchUsedMotorsCriteria)
			{
				CriteriaUsedCarsModel.Criteria = criteria as SearchUsedMotorsCriteria;
				DoUsedCarsSearch(CriteriaUsedCarsModel.Criteria);
			}
            if (criteria is SearchBoatsCriteria)
            {
                CriteriaBoatsModel.Criteria = criteria as SearchBoatsCriteria;
                DoBoatsSearch(CriteriaBoatsModel.Criteria);
            }
            if (criteria is SearchJobsCriteria)
            {
                CriteriaJobsModel.Criteria = criteria as SearchJobsCriteria;
                DoJobSearch(CriteriaJobsModel.Criteria);
            }
            if (criteria is SearchResidentialCriteria)
            {
                CriteriaPropertyForSaleModel.Criteria = criteria as SearchResidentialCriteria;
                DoPropertyForSaleSearch(CriteriaPropertyForSaleModel.Criteria);
            }
            // TODO: Rental, OpenHome, Flatmates
        }

        public void DoGeneralSearch(SearchGeneralCriteria criteria)
        {
            string hash = criteria.GetHashCode().ToString();
        	//new TransientDataStore().Backup(hash, criteria);
            new IsolatedStorageRepository<SearchGeneralCriteria>(hash + ".criteria").Write(criteria);

            App.AppPage.NavigationService.Navigate(new Uri("/SearchResultsView.xaml?type=general&criteria=" + hash,
                                                           UriKind.Relative));
        }

		private void DoBikesSearch(SearchMotorBikesCriteria criteria)
		{
			string hash = criteria.GetHashCode().ToString();
			//new TransientDataStore().Backup(hash, criteria);
			new IsolatedStorageRepository<SearchMotorBikesCriteria>(hash + ".criteria").Write(criteria);

			App.AppPage.NavigationService.Navigate(new Uri("/SearchResultsView.xaml?type=bikes&criteria=" + hash,
														   UriKind.Relative));
		}

		private void DoUsedCarsSearch(SearchUsedMotorsCriteria criteria)
		{
			string hash = criteria.GetHashCode().ToString();
			//new TransientDataStore().Backup(hash, criteria);
			new IsolatedStorageRepository<SearchUsedMotorsCriteria>(hash + ".criteria").Write(criteria);

			App.AppPage.NavigationService.Navigate(new Uri("/SearchResultsView.xaml?type=usedcars&criteria=" + hash,
														   UriKind.Relative));
		}

        private void DoBoatsSearch(SearchBoatsCriteria criteria)
        {
            string hash = criteria.GetHashCode().ToString();
            //new TransientDataStore().Backup(hash, criteria);
            new IsolatedStorageRepository<SearchBoatsCriteria>(hash + ".criteria").Write(criteria);

            App.AppPage.NavigationService.Navigate(new Uri("/SearchResultsView.xaml?type=boats&criteria=" + hash,
                                                           UriKind.Relative));
        }

        private void DoJobSearch(SearchJobsCriteria criteria)
        {
            string hash = criteria.GetHashCode().ToString();
            //new TransientDataStore().Backup(hash, criteria);
            new IsolatedStorageRepository<SearchJobsCriteria>(hash + ".criteria").Write(criteria);

            App.AppPage.NavigationService.Navigate(new Uri("/SearchResultsView.xaml?type=jobs&criteria=" + hash,
                                                           UriKind.Relative));
        }

        private void DoPropertyForSaleSearch(SearchResidentialCriteria criteria)
        {
            string hash = criteria.GetHashCode().ToString();
            //new TransientDataStore().Backup(hash, criteria);
            new IsolatedStorageRepository<SearchResidentialCriteria>(hash + ".criteria").Write(criteria);

            App.AppPage.NavigationService.Navigate(new Uri("/SearchResultsView.xaml?type=residential&criteria=" + hash,
                                                           UriKind.Relative));
        }

        private void DoPropertyRentalSearch(SearchResidentialCriteria criteria)
        {
            string hash = criteria.GetHashCode().ToString();
            //new TransientDataStore().Backup(hash, criteria);
            new IsolatedStorageRepository<SearchResidentialCriteria>(hash + ".criteria").Write(criteria);

            App.AppPage.NavigationService.Navigate(new Uri("/SearchResultsView.xaml?type=rental&criteria=" + hash,
                                                           UriKind.Relative));
        }

        private void DoPropertyOpenHomeSearch(SearchResidentialCriteria criteria)
        {
            string hash = criteria.GetHashCode().ToString();
            //new TransientDataStore().Backup(hash, criteria);
            new IsolatedStorageRepository<SearchResidentialCriteria>(hash + ".criteria").Write(criteria);

            App.AppPage.NavigationService.Navigate(new Uri("/SearchResultsView.xaml?type=openhome&criteria=" + hash,
                                                           UriKind.Relative));
        }

        private void DoPropertyFlatmateSearch(SearchResidentialCriteria criteria)
        {
            string hash = criteria.GetHashCode().ToString();
            //new TransientDataStore().Backup(hash, criteria);
            new IsolatedStorageRepository<SearchResidentialCriteria>(hash + ".criteria").Write(criteria);

            App.AppPage.NavigationService.Navigate(new Uri("/SearchResultsView.xaml?type=flatmate&criteria=" + hash,
                                                           UriKind.Relative));
        }



        private List<Category> _rootCategories;
        public List<Category> RootCategories
        {
            get
            {
                if (_rootCategories == null)
                {
                    if (App.TradeMe.Catalog.RootCategory != null)
                        _rootCategories = App.TradeMe.Catalog.RootCategory.Subcategories;
                }
                return _rootCategories;
            }
            set { _rootCategories = value; NotifyPropertyChanged("RootCategories"); }
        }

        private Category _selectedCategory;
        public Category SelectedCategory
        {
            get { return _selectedCategory; }
            set
            {
                Breadcrumb.Clear();
                _selectedCategory = value;
                if (value == null)
                {
                    RootCategories = null;
                    NotifyPropertyChanged("SelectedCategory");
                    return;
                }

                if (value.Subcategories != null)
                    RootCategories = value.Subcategories;

                // Category="0002-0352-9333-9391-"
                // CategoryPath="/Computers/Apple/iPads/Cases-protectors"

                var catlist = App.TradeMe.CategoryTree(_selectedCategory.Number);
                foreach (var category in catlist)
                    Breadcrumb.Add(category);

                NotifyPropertyChanged("SelectedCategory");
            }
        }


        public void UpdateMyTradeMe()
        {
            NotifyPropertyChanged("LoggedIn");
            if (_lastUpdatedMyTradeMe < DateTime.Now.AddMinutes(-1))
                GetMyTradeMe();
        }

        private DateTime _lastUpdatedMyTradeMe;
        public void GetMyTradeMe()
        {
            _lastUpdatedMyTradeMe = DateTime.Now;

            App.TradeMe.MyTradeMe.MyTradeMeSummary(result =>
                        {
                            if (result.IsError)
                            {
                                MessageBox.Show("Bugger: Unable to retrieve My trade me summary");
                                return;
                            }

                            Summary = result.Response;
                        });
        }

        private MyTradeMeSummary _summary;
        public MyTradeMeSummary Summary
        {
            get { return _summary; }
            set
            {
                _summary = value; 
                NotifyPropertyChanged(new []
                                          {
                                              "Summary", "UniquePositive",
                                              "WatchList", "ItemsIWon", "ItemsILost",
                                              "SellingCount", "SoldCount", "UnsoldCount",
                                              "AccountBalance"
                                          });
            }
        }

        public string UniquePositive
        {
            get
            {
                if (Summary == null) return null;
                return string.Format("({0}) ", Summary.PositiveFeedback);
            }
        }

        public string WatchList 
        { 
            get
            {
                if (Summary == null) return null;
                if (Summary.WatchListCount == 0) return "Watch List";
                return string.Format("Watch list ({0})", Summary.WatchListCount);
            }
        }

        public string ItemsIWon
        {
            get
            {
                if (Summary == null) return null;
                if (Summary.WonCount == 0) return "Items I Won";
                return string.Format("Items I won ({0})", Summary.WonCount);
            }
        }

        public string ItemsILost
        {
            get
            {
                if (Summary == null) return null;
                if (Summary.LostCount == 0) return "Items I Lost";
                return string.Format("Items I lost ({0})", Summary.LostCount);
            }
        }

        public string SellingCount
        {
            get
            {
                if (Summary == null) return null;
                if (Summary.LostCount == 0) return "Selling";
                return string.Format("Selling ({0})", Summary.SellingCount);
            }
        }

        public string SoldCount
        {
            get
            {
                if (Summary == null) return null;
                if (Summary.LostCount == 0) return "Sold";
                return string.Format("Sold ({0})", Summary.SoldCount);
            }
        }

        public string UnsoldCount
        {
            get
            {
                if (Summary == null) return null;
                if (Summary.LostCount == 0) return "Unsold";
                return string.Format("Unsold ({0})", Summary.UnsoldCount);
            }
        }

        public string AccountBalance
        {
            get
            {
                if (Summary == null) return null;
                if (Summary.Balance == 0) return "empty";
                return string.Format("${0:0.00}", Summary.Balance);
            }
        }

    }
}
